

import UIKit
import TFAnimatedImage
class TF_VoiceLive: UIImageView {
    @objc public let avatar = UIImageView()
    let avatarBorder = UIView()
    let YView = UIView()
    let voice = UIView()
    let loadingExpression = TFAnimatedImageView()
    let title = UILabel()
 
    @objc public var moreShow:Bool = false
     override init(frame: CGRect) {
         super.init(frame: frame)
         self.image = UIImage.init(named: "HTLive.bundle/livingVoiceLive")
        
         
  
         self.avatarBorder.backgroundColor = UIColor(red: 255/255.0, green: 255/255.0, blue: 255/255.0, alpha: 1.0)
         
        
         self.addSubview(self.avatarBorder)
         
 
         self.avatar.contentMode = .scaleAspectFill
         self.avatar.layer.masksToBounds  =  true
         self.avatar.backgroundColor = UIColor(red: 255/255.0, green: 255/255.0, blue: 255/255.0, alpha: 1.0)
         self.avatarBorder.addSubview(self.avatar)
         
 
         self.voice.backgroundColor = UIColor(red: 0/255.0, green: 0/255.0, blue: 0/255.0, alpha: 0.73)
         self.addSubview(self.voice)
         
         
         self.loadingExpression.backgroundColor = UIColor.clear
         self.voice.addSubview(self.loadingExpression)
        let retinaPath = Bundle.main.path(forResource: "TF_VoiceLiveAnimation", ofType: "gif")
         if retinaPath != nil {
             if let data = NSData(contentsOfFile: retinaPath! as String) {
                 self.loadingExpression.animatedImage =  TFAnimatedImage.init(animatedGIFData: data as Data)
             }
         }

        
    

         self.title.textAlignment = .center
         self.title.numberOfLines = 0;
         self.addSubview(self.title)
         

         self.title.attributedText = NSMutableAttributedString.getAttributed(string: "语音直播中", font: UIFont.PingFang(size: 18), foregroundColor: UIColor(red: 255/255.0, green: 255/255.0, blue: 255/255.0, alpha: 1.0))
         
         self.title.textColor = UIColor(red: 255/255.0, green: 255/255.0, blue: 255/255.0, alpha: 1.0)
         
     }
    override func layoutSubviews() {
        super.layoutSubviews()
        
        let avatarBorderY:CGFloat = 139.0/667.0*self.frame.size.height
        self.avatarBorder.frame = CGRect(x: (self.frame.size.width - 110)/2, y: avatarBorderY, width: 110, height: 110)
       
        self.avatarBorder.layer.cornerRadius = self.avatarBorder.bounds.size.width / 2
        
        self.avatar.frame = CGRect(x: (self.avatarBorder.frame.size.width-95)/2, y: (self.avatarBorder.frame.size.height-95)/2, width: 95, height: 95)
        
        self.avatar.layer.cornerRadius = self.avatar.bounds.size.width / 2
        
        self.voice.frame = CGRect(x: self.avatarBorder.frame.maxX-35, y: self.avatarBorder.frame.maxY-35, width: 35, height: 35)
      
        self.voice.layer.cornerRadius = self.voice.bounds.size.width / 2;
        
        
        self.loadingExpression.frame = self.voice.bounds;

        
        self.title.frame = CGRect(x: 0, y: self.avatarBorder.frame.maxY+30, width: self.frame.size.width, height: 28)
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
 
}
